package jp.sourceforge.akjrcp.flvtools.basic;

import jp.sourceforge.akjrcp.akj_betas.Akj_betasPlugin;
import jp.sourceforge.akjrcp.akj_betas.Messages;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FileFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PathEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

import com.sun.corba.se.impl.io.FVDCodeBaseImpl;




/**
 * This class represents a preference page that
 * is contributed to the Preferences dialog. By 
 * subclassing <samp>FieldEditorPreferencePage</samp>, we
 * can use the field support built into JFace that allows
 * us to create a page that is small and knows how to 
 * save, restore and apply itself.
 * <p>
 * This page is used to modify preferences only. They
 * are stored in the preference store that belongs to
 * the main plug-in class. That way, preferences can
 * be accessed directly via the preference store.
 */


public class FLVToolsPage
	extends FieldEditorPreferencePage
	implements IWorkbenchPreferencePage {
	
	/*@deprecated*/
	//public static final String Monitor_DIR="monitor_dir";
	 
	public static final String PLAYER_PATH="basic.player_path";
	public static final String FLVTOOL2_PATH="flvtool2_path";
	public static final String PRIMARY_FLOWPLAYER="primary_flowplayer";
	
	public static final String FLV_EXTENSION_ADD="explorer.addextension";
	public static final String FLV_EXTENSION_ADD_AUTO="add_auto";
	public static final String FLV_EXTENSION_ADD_DIALOG="add_dialog";
	public static final String FLV_EXTENSION_ADD_NEVER="add_never";
	
	public static final String EXPLORER_PATHS="explorer.paths";
	public static final String EXPORT_SAME_DIRECTORY="explorer.export_same_directory";
	public static final String EXPORT_DIRECTORY="explorer.export_directory";
	public static final String SUPPORTED_EXTENSIONS="explorer.supported_extensions";
	public FLVToolsPage() {
		super(GRID);
		setPreferenceStore(Akj_betasPlugin.getDefault().getPreferenceStore());
		setDescription(Messages.getString("general_setting"));
		initializeDefaults();
	}
/**
 * Sets the default values of the preferences.
 */
	private void initializeDefaults() {
		
	}
	
/**
 * Creates the field editors. Field editors are abstractions of
 * the common GUI blocks needed to manipulate various types
 * of preferences. Each field editor knows how to save and
 * restore itself.
 */

	

    protected void createFieldEditors() {
    //	log.info(getPreferenceStore().getString(EXPLORER_PATHS));
    	  addField(new PathEditor(
				  EXPLORER_PATHS,
					Messages.getString("explorer.paths_label"),Messages.getString("explorer.paths_choose") ,getFieldEditorParent()));
        
    	  
    	//DirectoryFieldEditor fileField=new DirectoryFieldEditor(Monitor_DIR, Messages.getString("monitor_dir"),getFieldEditorParent());
    	  addField(new BooleanFieldEditor(EXPORT_SAME_DIRECTORY,Messages.getString("explorer.export_same_directory"),getFieldEditorParent()));
    	  addField(new DirectoryFieldEditor(EXPORT_DIRECTORY,Messages.getString("explorer.export_directory"),getFieldEditorParent()));
        //addField(fileField);
        
        addField(new BooleanFieldEditor(PRIMARY_FLOWPLAYER,Messages.getString("primary_flowplayer"),getFieldEditorParent()));
    	
        FileFieldEditor exeField=new FileFieldEditor(
                PLAYER_PATH, Messages.getString("player_path"),getFieldEditorParent()); //$NON-NLS-1$
        exeField.setFileExtensions(new String[]{"*.exe"}); //$NON-NLS-1$
        addField(exeField);
        
        FileFieldEditor flvtool2Field=new FileFieldEditor(
                FLVTOOL2_PATH, Messages.getString("fvltool2_path"),getFieldEditorParent()); //$NON-NLS-1$
        flvtool2Field.setFileExtensions(new String[]{"flvtool2.exe"}); //$NON-NLS-1$
        addField(flvtool2Field);
        
        addField(new RadioGroupFieldEditor(
		        FLV_EXTENSION_ADD,
				Messages.getString("flv_extension_add"), // //$NON-NLS-1$
				4,
				new String[][] { { Messages.getString("flv_extension_add_auto"), FLV_EXTENSION_ADD_AUTO }, {
					//$NON-NLS-1$ //$NON-NLS-2$
					Messages.getString("flv_extension_add_dialog"), FLV_EXTENSION_ADD_DIALOG  //$NON-NLS-1$ //$NON-NLS-2$
				    
				},
				{
				Messages.getString("flv_extension_add_never"), FLV_EXTENSION_ADD_NEVER  //$NON-NLS-1$ //$NON-NLS-2$
			    
				}
				
			}, getFieldEditorParent()));
        
        addField(new StringFieldEditor(SUPPORTED_EXTENSIONS,Messages.getString(SUPPORTED_EXTENSIONS),getFieldEditorParent())); //$NON-NLS-1$
		
        
    }
	
	public void init(IWorkbench workbench) {
	}
}